var appInstance = getApp()
Page({
  data: {
    focus: false,
    inputValue:0,
    year: appInstance.data.year,
    month: appInstance.data.month,
    openid: appInstance.globalData.openid
  },
  // 确定按钮点击事件，插入月预算
  bindButtonTap: function () {
    if (this.data.inputValue==0){
      wx.showModal({
        title: '提示',
        content: '预算不能为空！',
      })
    }else{
    var that = this;
    wx.request({
      url: 'https://hi.slickghost.com/WebTest/Operate',
      header: {
        'content-type': 'json'
      },
      data: {
        choice: 'insertbudget',
        openid: appInstance.globalData.openid,
        money: that.data.inputValue
      },
      success: function (res) {
        var t1=this;
      }
    })
    appInstance.globalData.budget = that.data.inputValue;
    this.setData({
      focus: true
    })
    this.showok();
  }},
  // 按钮点击确定后弹窗
  showok: function () {
    wx.showToast({
      title: '设置成功',
      icon: 'success',
      duration: 2000
    })
  },

  // 获取预算值插入数据
  bindKeyInput: function (e) {
    this.setData({
      inputValue: parseInt(e.detail.value)
    })
  }
  
})
